var themes_obj = {
  /**
   * 表格内全选功能
   * @author Ziruo
   * @param object data 数据对象
   * obj 表单对象
   */
  selectAll: (data = {}) => {
    let table = data.obj ? data.obj : $("body");
    let box = table.find(".selector_box");
    let all = table.find(".selector input[type=checkbox][name=select_all]");
    let select = table.find(".selector input[type=checkbox][name=select]");
    select.on("click", function () {
      let checkedLength = table.find(
        ".selector input[type=checkbox][name=select]:checked"
      ).length;
      checkedLength > 0 ? box.addClass("open") : box.removeClass("open");
      box.find(".tips span").text(checkedLength);
      checkedLength == select.length
        ? all.prop("checked", true)
        : all.prop("checked", false);
    });
    all.on("click", function () {
      $(this).prop("checked") == true
        ? select.prop("checked", true)
        : select.prop("checked", false);
      $(this).prop("checked") == true
        ? box.addClass("open")
        : box.removeClass("open");
      let checkedLength = table.find(
        ".selector input[type=checkbox][name=select]:checked"
      ).length;
      box.find(".tips span").text(checkedLength);
    });
  },

  /**
   * 右侧弹窗
   * @param object data 数据对象
   * clickClass 触发点击类名
   * targetClass 目标弹窗类名
   * check 检查函数
   * ready 弹窗打开前函数
   * submit 提交函数
   * cancel 取消函数
   */
  fixedRight: (data = {}) => {
    let clickClass = data.click;
    let targetClass = data.target;
    let check = data.check;
    let ready = data.ready;
    let submit = data.submit;
    let cancel = data.cancel;
    let boxWidth = $(targetClass).data("width");
    if (boxWidth) $(targetClass).width(boxWidth);
    $(document).on("click", clickClass, function () {
      if ($.isFunction(check) && !check.call()) return false;
      if ($.isFunction(ready)) ready.call(this, $(this));
      global_obj.div_mask();
      $(targetClass).addClass("current");
    });
    // $(clickClass).on('click', function(){
    // 	if ($.isFunction(check) && !check.call()) return false;
    // 	if ($.isFunction(ready)) ready.call(this, $(this));
    // 	global_obj.div_mask();
    // 	$(targetClass).addClass('current');
    // });
    $(document).on(
      "click",
      `body ${targetClass} .top_title a, #div_mask`,
      function () {
        global_obj.div_mask(1);
        $(targetClass).removeClass("current");
      }
    );
    // $('body').on('click', `${targetClass} .top_title a, #div_mask`, function(){
    // 	global_obj.div_mask(1);
    // 	$(targetClass).removeClass('current');
    // });
    $(document).on(
      "click",
      `${targetClass} .bottom_button .button[name=cancel]`,
      function () {
        $(`${targetClass} .top_title a`).trigger("click");
        if ($.isFunction(cancel)) cancel.call();
      }
    );
    // $(`${targetClass} .bottom_button .button[name=cancel]`).on('click', function(){
    // 	$(`${targetClass} .top_title a`).trigger('click');
    // 	if ($.isFunction(cancel)) cancel.call();
    // });
    $(document).on(
      "click",
      `${targetClass} .bottom_button .button[name=submit]`,
      function () {
        if ($.isFunction(submit)) submit.call();
      }
    );
    // $(`${targetClass} .bottom_button .button[name=submit]`).on('click', function(){
    // 	if ($.isFunction(submit)) submit.call();
    // });
  },

  /**
   * 判断是否已经登陆
   */
  isLogin: () => {
    $.ajax({
      url: "/?do_action=action.user_limit_log",
      type: "post",
      dataType: "json",
      data: { Type: "isLogin" },
      success: function (result) {
        if (parseInt($("#AccountId").val()) == 0) return false;
        return true;
      },
    });
  },

  /**
   * 登陆弹窗
   */
  loginBox: ($bf = "", $regf = "") => {
    // $.ajax({
    // 	url:'/checkLogin',
    // 	type:'post',
    // 	dataType:'json',
    // 	data:{'Type':'loginBox','Bf':$bf,'regf':$regf},
    // 	success:function(result){
    // 		if (result.code === 0) {
    // 			global_obj.div_mask();
    // 			$('.user_login_box').show();
    // 		}
    // 	}
    // });
    global_obj.div_mask();
    $(".user_login_box").show();
  },

  /**
   * 优化弹窗-清晰引导注册
   */
  memberReminderBox: ($bf = "", $regf = "") => {
    $.ajax({
      url: "/?do_action=action.user_limit_log", //记录操作日志
      type: "post",
      dataType: "json",
      data: { Type: "memberReminderBox", Bf: $bf, regf: $regf },
      success: function (result) {
        // global_obj.div_mask(); //弹出遮罩层
        if ($(".top_header_fixed .add_alert").length) {
          $(".member_reminder_box .no_b").html(
            lang_obj.user.login.reminder_title
          );
        }
        if ($(".turn_page_no_permit").length) {
          $(".turn_page_no_permit").remove();
        }
        $(".member_reminder_box").show();
      },
    });
  },

  /**
   * 支付弹窗
   */
  upgradeBox: (
    $bf = "",
    $type = "system",
    $version = "upgrade",
    $level = 0,
    $times = "year"
  ) => {
    // $.ajax({
    // 	url:'/?do_action=action.user_limit_log',
    // 	type:'post',
    // 	dataType:'json',
    // 	data:{'Type':'upgradeBox','Bf':$bf},
    // 	success:function(result){
    // 		global_obj.div_mask();
    // 		if($type == 'system'){
    // 			$('.global_alert_upgrade .prompt_box').addClass('system');
    // 		}else{
    // 			$('.global_alert_upgrade .prompt_box.system').removeClass('system');
    // 		}
    // 		$('.global_alert_upgrade .bf').val($bf);
    // 		/*
    // 		if($level==11){
    // 			$('.global_alert_upgrade').addClass('add_level');
    // 		}else{
    // 			$('.global_alert_upgrade').removeClass('add_level');
    // 		}
    // 		*/
    // 		if ($('.turn_page_no_permit').length) {
    // 			$('.turn_page_no_permit').hide();
    // 		}
    // 		if($times=='month'){
    // 			$('.global_alert_upgrade .price_change .show_month').click();
    // 		}else{
    // 			$('.global_alert_upgrade .price_change .show_year').click();
    // 		}
    // 		$('.global_alert_upgrade').addClass('cur');
    // 		//优惠券计算
    // 		$('.global_alert_upgrade .upgrade_level_box_new_plus').each(function (){
    // 			if($(this).hasClass('cur')){
    // 				$(this).click();
    // 			}
    // 		})
    // 		/*
    // 		if (parseInt($('#Level').val()) == 0) {
    // 			$('.global_alert_upgrade').removeClass('version_upgrade')
    // 		} else {
    // 			$('.global_alert_upgrade').addClass('version_upgrade')
    // 		}
    // 		*/
    // 		if ($version == 'renew' && $('#Level').val()>10) {
    // 			$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label input[value='+$('#Level').val()+']').parents('label').click();
    // 		} else {
    // 			if($level){
    // 				$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label input[value='+$level+']').parents('label').click();
    // 			}else{
    // 				if($type == 'market'){
    // 					$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label').eq(2).click();
    // 				}else{
    // 					$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label').eq(0).click();
    // 				}
    // 			}
    // 		}
    // 	}
    // });

    global_obj.div_mask();
    if ($type == "system") {
      $(".global_alert_upgrade .prompt_box").addClass("system");
    } else {
      $(".global_alert_upgrade .prompt_box.system").removeClass("system");
    }
    $(".global_alert_upgrade .bf").val($bf);
    if ($(".turn_page_no_permit").length) {
      $(".turn_page_no_permit").hide();
    }
    $(".global_alert_upgrade").addClass("cur");
    //优惠券计算
    $(".global_alert_upgrade .upgrade_level_box_new_plus").each(function () {
      if ($(this).hasClass("cur")) {
        $(this).click();
      }
    });
    if ($version == "renew" && $("#Level").val() > 10) {
      $(".global_alert_upgrade")
        .find(
          ".upgrade_level_box_new_plus label input[value=" +
            $("#Level").val() +
            "]"
        )
        .parents("label")
        .click();
    } else {
      if ($level) {
        $(".global_alert_upgrade")
          .find(".upgrade_level_box_new_plus label input[value=" + $level + "]")
          .parents("label")
          .click();
      } else {
        // if($type == 'market'){
        // 	$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label').eq(2).click();
        // }else{
        // 	$('.global_alert_upgrade').find('.upgrade_level_box_new_plus label').eq(0).click();
        // }
      }
    }
  },

  /**
   * 不够权限查看
   */
  noViewBox: (
    accountid,
    bf = "",
    num = "",
    name = "",
    desc_name = "no_view_desc",
    unit = "",
    is_img = 0
  ) => {
    let _returnHtml = "";
    let _thisStatus = accountid > 0 ? "member" : "visitors";
    let _tipsData = {
      visitors: {
        tips1: lang_obj.user.level.no_view_1,
        tips2: lang_obj.user.level.no_view_2,
        tips3: lang_obj.user.level.no_view_3,
        tips4: lang_obj.user.level.no_view_4,
        title: lang_obj.user.level[desc_name]
          .replace("%num%", num)
          .replace("%name%", name)
          .replace("%unit%", unit),
        img: zuoooo_config.consultant.b_qrcode,
        contact: lang_obj.user.level.no_view_contact,
        tips_upgrade_cut: lang_obj.price.tips_upgrade_cut,
        btn: {
          go_register: lang_obj.user.register.signup_free,
          go_login: lang_obj.user.level.login,
        },
      },
      member: {
        tips1: lang_obj.user.level.no_view_1,
        tips2: lang_obj.user.level.no_view_2,
        tips3: lang_obj.user.level.no_view_3,
        tips4: lang_obj.user.level.no_view_4,
        title: lang_obj.user.level.no_view_title,
        img: zuoooo_config.consultant.b_qrcode,
        contact: lang_obj.user.level.no_view_contact,
        tips_upgrade_cut: lang_obj.price.tips_upgrade_cut,
        btn: {
          go_upgrade: lang_obj.user.level.upgrade_now,
        },
      },
    };
    let = _tipsBtnHtml = "";
    for (k in _tipsData[_thisStatus].btn) {
      let _thisText = _tipsData[_thisStatus].btn[k];
      let _thisUrl = "javascript:;";
      if (k == "go_register") {
        _thisUrl = '/register.html?IsLevel=1" target="_blank';
      }
      _tipsBtnHtml += `<a href="${_thisUrl}" class="${k}" bf="${bf}">${_thisText}</a>`;
    }
    let = _imgHtml = "";
    if ($("#IsLastOrders").val() > 0) {
      _imgHtml = `<div class="tips_upgrade_cut"><i></i><span>${_tipsData[_thisStatus].tips_upgrade_cut}</span></div>`;
    }
    if (is_img) {
      _imgHtml = `<div class="tips_contact"><img src="${_tipsData[_thisStatus].img}" alt="wechat">${_tipsData[_thisStatus].contact}</div>`;
    }
    if (accountid > 0) {
      _returnHtml += `
				<div class="no_view_tip_box upgrade">
					<div class="right_cont">
						<div class="tips_title">${_tipsData[_thisStatus].title}<a href="javascript:;" class="close"></a></div>
						<div class="tips_list">
							<span>${_tipsData[_thisStatus].tips1}</span>
							<span>${_tipsData[_thisStatus].tips2}</span>
							<span>${_tipsData[_thisStatus].tips3}</span>
							<span>${_tipsData[_thisStatus].tips4}</span>
						</div>
						<div class="tips_btn_info">${_tipsBtnHtml}</div>
						${_imgHtml}
					</div>
				</div>
			`;
    } else {
      _returnHtml += `
				<div class="no_view_tip_box">
					<div class="right_cont">
						<div class="tips_title">${_tipsData[_thisStatus].title}</div>
						<div class="tips_btn_info">${_tipsBtnHtml}</div>
						${_imgHtml}
					</div>
				</div>
			`;
    }
    return _returnHtml;
  },

  /**
   * 未找到X国数据
   * tips：提示内容
   * keyword：关键字
   */
  noFoundData: (result = {}, RoleName = "") => {
    let _returnHtml = "";
    let consultant = result;

    _returnHtml = '<div class="list_empty">';
    _returnHtml += '<div class="img">';
    _returnHtml += '<img src="static/image/list_empty.png">';
    let keywork = $(".search_box input[name=Country2]").val();
    if (keywork) {
      let no_match = lang_obj.clue.detail.no_match_keywork;
      no_match = no_match.replace("%keywork%", keywork);
      no_match = no_match.replace(
        "%role%",
        Role == 1 ? lang_obj.header.supplier : lang_obj.header.buyer
      );
      _returnHtml += "<span>" + no_match + "</span>";
    } else if (RoleName) {
      _returnHtml +=
        "<span>" + lang_obj.clue.list.no_match_threads + RoleName + "</span>";
    } else {
      _returnHtml +=
        "<span>" +
        lang_obj.clue.list.no_match_threads +
        (Role == 1 ? lang_obj.header.supplier : lang_obj.header.buyer) +
        "</span>";
    }
    _returnHtml += "</div>";
    _returnHtml += '<div class="consultant_box">';
    _returnHtml += '<div class="c_box_content">';
    _returnHtml +=
      '<div class="c_box_title">' +
      lang_obj.clue.detail.consultant_title +
      "<span>" +
      lang_obj.clue.list.consultant +
      "</span></div>";
    _returnHtml +=
      '<div class="c_box_desc">' +
      lang_obj.clue.list.consultant_desc +
      "</div>";
    _returnHtml +=
      '<div class="c_box_phone line">' +
      lang_obj.clue.list.consultant_phone +
      ":<span>" +
      consultant.phone +
      "</span></div>";
    _returnHtml +=
      '<div class="c_box_email line">' +
      lang_obj.clue.list.consultant_email +
      ":<span>1049730000@qq.com</span></div>";
    _returnHtml += "</div>";
    _returnHtml += '<div class="c_box_qrcode">';
    _returnHtml +=
      '<div class="qrcode"><img src="' +
      consultant.qrcode +
      '" alt="' +
      consultant.name +
      '"></div>';
    _returnHtml +=
      '<div class="c_q_desc">' + lang_obj.clue.list.qrcode_desc + "</div>";
    _returnHtml += "</div>";
    _returnHtml += "</div>";
    _returnHtml += "</div>";

    return _returnHtml;
  },

  /**
   * 未找到企业数据
   * result：数据
   */
  noFoundEnterpriseData: (result = {}) => {
    let consultant = result;

    // global_obj.div_mask(0,'enterprise_data_mask');//弹出遮罩层
    $(".enterprise_data_box .c_box_content .c_box_phone span").html(
      consultant.phone
    );
    $(".enterprise_data_box .c_box_qrcode .qrcode img").attr({
      src: consultant.qrcode,
      alt: consultant.name,
    });

    $(".enterprise_data_box").show();
  },

  /**
   * 限时特惠弹窗
   */
  flashSaleBox: (title, content, type, time) => {
    let html = "";
    html += '<div class="flash_sale_box">';
    if (type == "national_day") {
      html +=
        '<div class="flash_sale national_day"><div class="flash_sale_close"></div>';
      html +=
        '<a href="/price/" class="f_s_button">' +
        lang_obj.global.buy_now +
        "</a>";
    }
    html += "</div>";
    $("body").prepend(html);
    $(".flash_sale_box").css({ top: "30%" });
    $(".flash_sale_box").on(
      "click",
      ".flash_sale .flash_sale_close",
      function () {
        $(".flash_sale_box").remove();
        themes_obj.updateFS();
      }
    );
    setTimeout(function () {
      $(".flash_sale_box").remove();
    }, time);
  },

  /**
   * 更新限时特惠
   */
  updateFS: () => {
    $.ajax({ url: "/?do_action=action.update_flash_sale", type: "get" });
  },

  /**
   * 首次进入网站显示向导
   */
  firstShow: (type) => {
    let default_html = lang_obj.footer.first_show_html
      .replaceAll("%title%", lang_obj.footer.first_show[type - 1].title)
      .replaceAll("%content%", lang_obj.footer.first_show[type - 1].content)
      .replaceAll("%confirm%", lang_obj.footer.first_show[type - 1].confirm)
      .replaceAll("%num%", type);
    $("html, body").animate(
      {
        scrollTop: 0,
      },
      0
    );
    $("body").attr("style", "overflow: hidden;");
    $(".first_show_out").html(default_html);
    $(".first_show_out .search_tips_alert").show();
    $("#header").removeClass("before");
    $("#banner")
      .addClass("before")
      .removeClass("first_show_type_2")
      .removeClass("first_show_type_3")
      .removeClass("first_show_type_4")
      .removeClass("first_show_type_5");
    if (type == 1) {
      $(".first_show_out .search_tips_alert")
        .attr("style", "left: 50%;top: 50%;transform: translate(-50%, -50%);")
        .show();
    } else if (type == 2) {
      $("#banner").addClass("first_show_type_2");
      if (window.innerWidth > 1024) {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .tags .item").eq(1).offset().left +
                $("#banner .tags .item").eq(1).outerWidth() +
                8) +
              "px;top: " +
              $("#banner .tags .item").eq(1).offset().top +
              "px;"
          )
          .show();
      } else {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .tags").eq(0).offset().left +
                ($("#banner .tags").eq(0).outerWidth() -
                  $(".first_show_out .search_tips_alert").eq(0).outerWidth()) /
                  2) +
              "px;top: " +
              ($("#banner .tags").eq(0).offset().top +
                $("#banner .tags").eq(0).outerHeight() +
                8) +
              "px;"
          )
          .show();
      }
    } else if (type == 3) {
      $("#banner").addClass("first_show_type_3");
      if (window.innerWidth > 1024) {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .search form .fiter").eq(0).offset().left +
                $("#banner .search form .fiter").eq(0).outerWidth() +
                8) +
              "px;top: " +
              $("#banner .search form .fiter").eq(0).offset().top +
              "px;"
          )
          .show();
      } else {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .search form .fiter").eq(0).offset().left +
                $("#banner .search form .fiter").eq(0).outerWidth() +
                8) +
              "px;top: " +
              $("#banner .search form .fiter").eq(0).offset().top +
              "px;max-width: calc( 96vw - " +
              ($("#banner .search form .fiter").eq(0).offset().left +
                $("#banner .search form .fiter").eq(0).outerWidth() +
                8) +
              "px );"
          )
          .show();
      }
    } else if (type == 4) {
      $("#banner").addClass("first_show_type_4");
      if (window.innerWidth > 1024) {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .search form .input_box").eq(0).offset().left +
                ($("#banner .search form .input_box").eq(0).outerWidth() -
                  $(".first_show_out .search_tips_alert").eq(0).outerWidth()) /
                  2) +
              "px;top: " +
              ($("#banner .search form .input_box").eq(0).offset().top +
                $("#banner .search form .input_box").eq(0).outerHeight() +
                8) +
              "px;"
          )
          .show();
      } else {
        $(".first_show_out .search_tips_alert")
          .attr(
            "style",
            "left: " +
              ($("#banner .search form .input_box").eq(0).offset().left +
                ($("#banner .search form .input_box").eq(0).outerWidth() -
                  $(".first_show_out .search_tips_alert").eq(0).outerWidth()) /
                  2) +
              "px;top: " +
              ($("#banner .search form .input_box").eq(0).offset().top +
                $("#banner .search form .input_box").eq(0).outerHeight() +
                8) +
              "px;max-width: calc( 96vw - " +
              ($("#banner .search form .input_box").eq(0).offset().left +
                ($("#banner .search form .input_box").eq(0).outerWidth() -
                  $(".first_show_out .search_tips_alert").eq(0).outerWidth()) /
                  2) +
              "px );"
          )
          .show();
      }
    } else if (type == 5) {
      $("#banner").removeClass("before").addClass("first_show_type_5");
      $("#header").addClass("before");
      $(".first_show_out .search_tips_alert")
        .attr(
          "style",
          "left: " +
            ($("#header .member .register").eq(0).offset().left +
              $("#header .member .register").eq(0).outerWidth() -
              $(".first_show_out .search_tips_alert").eq(0).outerWidth()) +
            "px;top: " +
            ($("#header .member .register").eq(0).offset().top +
              $("#header .member .register").eq(0).outerHeight() +
              8) +
            "px;"
        )
        .show();
    }
    if (type < 5) {
      $(".first_show_out .s_t_btn").on("click", function () {
        themes_obj.firstShow(type + 1);
      });
    } else {
      $(".first_show_out .s_t_btn").on("click", function () {
        themes_obj.firstShowClose();
      });
    }
    $(".first_show_out .close,.first_show_out .s_tips").on(
      "click",
      function () {
        themes_obj.firstShowClose();
      }
    );
  },

  firstShowClose: (type) => {
    $.ajax({
      url: "/?do_action=action.first_show_close",
      type: "get",
      dataType: "json",
      data: {},
      success: function (result) {
        $(".first_show_out").html("");
        window.location.reload();
      },
    });
  },

  recordUserModel: (type) => {
    $.ajax({
      url: "/?do_action=action.recordUserModel",
      type: "post",
      dataType: "json",
      data: { Type: type },
      success: function (result) {},
    });
  },
};

$(() => {
  if ($(".ai_loading").length) {
    let d_out = $(".ai_loading .d_out");
    let num = 0;
    setInterval(function () {
      num = parseInt(d_out.attr("num")) + 1;
      if (num > 3) {
        num = 1;
      }
      d_out.attr("num", num);
      $(".ai_loading .d_out")
        .removeClass("type1")
        .removeClass("type2")
        .removeClass("type3")
        .addClass("type" + num);
    }, 300);
  }

  jQuery(function () {
    var f = (ks = o = series = group = s = c = "");
    var para = window.location.search.replace("?", "");
    if (para != "") {
      var ary = para.split("&");
      for (i = 0; i < ary.length; i++) {
        var v = ary[i].split("=");
        if (v[0] == "f" && v[1] != "") {
          f = "&" + v[0] + "=" + v[1];
        } else if (v[0] == "k" && v[1] != "") {
          ks = "&" + v[0] + "=" + v[1];
        } else if (v[0] == "o" && v[1] != "") {
          o = "&" + v[0] + "=" + v[1];
        } else if (v[0] == "series" && v[1] != "") {
          series = "&" + v[0] + "=" + v[1];
        } /*else if(v[0]=='group' && v[1]!=''){
					group='&'+v[0]+'='+v[1];
				}*/ else if (v[0] == "s" && v[1] != "") {
          s = "&" + v[0] + "=" + v[1];
        } else if (v[0] == "c" && v[1] != "") {
          c = "&" + v[0] + "=" + v[1];
        }
      }

      if ((f != "" && ks != "") || s != "" || c != "") {
        jQuery(window).on("click", "a", function () {
          var url = "" + $(this).attr("href");
          if (/^\/(.*)$/g.test(url) || /^http(.*)$/g.test(url)) {
            if (/^(.*)\?(.*)$/g.test(url)) {
              url = url + f + ks + o + series + group + s + c;
            } else {
              url = url + "?" + f + ks + o + series + group + s + c;
            }
            $(this).attr("href", url);
          }
        });
      }
    }
  });
  $(window).scroll(function () {
    var window_top = $(window).scrollTop();
    if (window_top > 0) {
      $("#go_top").fadeIn().css("display", "block");
    } else {
      $("#go_top").fadeOut();
    }
  });
  $("#go_top").click(function () {
    $("html, body").animate({ scrollTop: 0 }, 700);
  });

  $("#turn_page,.alert_turn_page").on("click", "a", function () {
    if ($(this).parents("#turn_page").hasClass("level")) {
      if ($("#AccountId").val() > 0) {
        if (!$(".turn_page_no_permit").length) {
          var no_html = "";
          no_html += '<div class="turn_page_no_permit">';
          no_html += themes_obj.noViewBox($("#AccountId").val());
          no_html += "</div>";
          $("body").append(no_html);
        }
        global_obj.div_mask();
        $(".turn_page_no_permit").show();
      } else {
        themes_obj.loginBox("page");
        return false;
      }
      return false;
    } else {
      if (
        parseInt($("#AccountId").val()) > 0 ||
        $(this).parents("#turn_page").hasClass("no_limit")
      ) {
        // themes_obj.recordUserModel('PageTurn');
      } else {
        if ($(".global_alert_box.cur")) {
          $(".global_alert_box.cur").removeClass("cur");
        }
        themes_obj.loginBox("page");
        return false;
      }
    }
  });

  $("input[name=Times]").keydown(function (e) {
    var value = $(this).val(),
      key = window.event ? e.keyCode : e.which;
    if (key == 8) {
      return false;
    }
  });

  //点击框外，隐藏全部弹框
  $("html")
    .on("click", "#div_mask", function () {
      if ($(".global_alert_payment.cur").length) {
        $(".global_alert_payment").removeClass("cur");
        global_obj.div_mask();
        themes_obj.upgradeBox("payment");
      } else {
        $("#div_mask,#default_language_box").fadeOut(function () {
          global_obj.div_mask(1);
        });
        if ($(".global_alert_box.cur").length) {
          $(".global_alert_box").removeClass("cur");
        }
        if ($(".new_dig_box.cur").length) {
          $(".new_dig_box").removeClass("cur");
        }
        if ($(".global_alert_upgrade.cur").length) {
          $(".global_alert_upgrade .prompt_box.system").removeClass("system");
          $(".global_alert_upgrade").removeClass("cur");
        }
        $(".member_reminder_box").hide();
        $(".user_login_box").hide();
        if ($(".new_win_alert").length) {
          $(".new_win_alert").remove();
        }
        if ($(".mobile_fixed_menu").length) {
          $(".mobile_fixed_menu").removeClass("current");
        }
        if ($(".main_list .left_side.current").length) {
          $(".main_list .left_side.current").removeClass("current");
        }
        if ($(".global_fixed_right.country_box").length) {
          $(".global_fixed_right.country_box").removeClass("current");
        }
        if ($(".global_alert_box.alert_partner").length) {
          $(".global_alert_box.alert_partner").removeClass("cur");
        }
        if ($(".language_alert_box").length) {
          $(".language_alert_box").remove();
        }
        if ($(".video_alert").length) {
          $(".video_alert .video_box embed").remove();
          $(".video_alert").hide();
        }
        if ($(".available_num_reminder_box").length) {
          $(".available_num_reminder_box").hide();
        }
        if ($(".view_contact_info_box").length) {
          $(".view_contact_info_box").removeClass("cur");
          $("body").css("overflow", "auto");
        }
        if ($(".advanced_search_box").length) {
          $(".advanced_search_box").hide();
        }
        if ($(".turn_page_no_permit").length) {
          $(".turn_page_no_permit").hide();
        }
      }
    })
    .on("keyup", "#turn_page .jump_page", function () {
      let max = parseInt($(this).attr("max"));
      let val = parseInt($(this).val());
      if (val < 1 || isNaN(val)) {
        val = 1;
      } else if (val > max) {
        val = max;
      }
      $(this).val(val);
    })
    .on("click", "#turn_page .jump a", function () {
      let parents = $(this).parents("#turn_page");
      let val = parseInt(parents.find(".jump_page").val());
      if (isNaN(val)) {
        parents.find(".jump_page").attr("style", "border-color:#f00;");
        return false;
      } else {
        parents.find(".jump_page").removeAttr("style");
        let jump_page = parents.find(".jump_page").attr("link");
        window.location.href = jump_page.replace("{jump_page}", val);
      }
    })
    .on(
      "click",
      "a.detail_url,a.detail_name_url,a.company_detail_url,a.focus_url",
      function () {
        let md5 = $(this).attr("attr-href");
        let company = $(this).attr("attr-company");
        let role = $(this).attr("attr-role");
        let cid = $(this).attr("attr-cid");
        if (md5) {
          $.ajax({
            url: "/?do_action=action.get_detail_url",
            type: "post",
            dataType: "json",
            data: { Md5: md5, Company: company, Role: role, CId: cid },
            success: function (result) {
              /*
					if(result.ret==1){
						var userAgent = navigator.userAgent;
						var isiOS = userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
						if(isiOS){
							window.location.href = result.msg;
						}else{
							window.open(result.msg);
						}
						return true;
					}else{
						if(parseInt($('#AccountId').val())==0){
							global_obj.new_win_alert(result.msg,function(){
								themes_obj.loginBox('get_detail_url');
							},'alert',1,'none','登录会员');
						}else{
							global_obj.new_win_alert(result.msg,function(){
								global_obj.div_mask();
								$('.global_alert_upgrade').addClass('cur');
							},'alert',1,'none','马上升级');
						}
						return false;
					}
					*/
            },
          });
        }
      }
    )
    .on("click", ".is_level_click", function () {
      //详情页点击事件-贸易数据...
      let level = parseInt($(this).attr("level"));
      let bf = $(this).attr("bf");
      let regf = $(this).attr("regf");
      if (parseInt($("#AccountId").val()) == 0) {
        themes_obj.memberReminderBox(bf, regf);
      } else {
        themes_obj.upgradeBox(bf);
      }
      return false;
    })
    .on("click", ".no_view_tip_box .tips_contact a", function () {
      themes_obj.memberReminderBox("noViewBox", "noViewBox");
    })
    .on("click", ".no_view_tip_box .tips_title a", function () {
      if ($(this).parents(".no_view").length) {
        window.location.href = document.referrer;
      } else {
        global_obj.div_mask(1);
        $(".turn_page_no_permit").hide();
      }
    });
  // 移动端导航弹窗
  $("#header .menu").on("click", function () {
    global_obj.div_mask();
    $(".mobile_fixed_menu").addClass("current");
  });
  $(".mobile_fixed_menu .close").on("click", function () {
    global_obj.div_mask(1);
    $(".mobile_fixed_menu").removeClass("current");
  });
  $("body").on("click", ".go_upgrade", function () {
    if (parseInt($("#AccountId").val())) {
      let bf = $(this).attr("bf");
      if ($(".global_alert_box.cur")) {
        $(".global_alert_box.cur").removeClass("cur");
      }
      themes_obj.upgradeBox(bf);
      return false;
    }
  });
  $("body").on("click", ".no_view_tip_box .go_login", function () {
    themes_obj.loginBox("no_view_tip_box");
  });

  $(".landing_item .btn,.develop_box .btn,#banner").on(
    "click",
    ".video",
    function () {
      global_obj.div_mask();
      $(".video_alert .video_box").append(
        '<video width="100%" height="100%;" controls="controls" src="/assets/site_resource/file/c30b33a43b0d40c98d4bf1a8ea967849-113eaa834d0e97ee061dd285f9777d12-hd.mp4">'
      );
      $(".video_alert").show();
    }
  );
  $(".video_alert .video_box").on("click", "i", function () {
    global_obj.div_mask(1);
    $(".video_alert .video_box video").remove();
    $(".video_alert").hide();
  });
});

$.fn.processZoneOffsetData = function () {
  var time = new Date(),
    localOffset = time.getTimezoneOffset(),
    totalOffset = localOffset + zuoooo_config.offsetTime,
    local = time.getTime(),
    serviceTime = local + totalOffset * 60 * 1000;

  return new Date(serviceTime);
};

Number.prototype.formatMoney = function (places, decimal, thousand) {
  places = !isNaN((places = Math.abs(places))) ? places : 2;
  thousand = thousand || ",";
  decimal = decimal || ".";
  var number = this,
    negative = number < 0 ? "-" : "",
    i = parseInt((number = Math.abs(+number || 0).toFixed(places)), 10) + "",
    j = (j = i.length) > 3 ? j % 3 : 0;
  return (
    negative +
    (j ? i.substr(0, j) + thousand : "") +
    i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) +
    (places
      ? decimal +
        Math.abs(number - i)
          .toFixed(places)
          .slice(2)
      : "")
  );
};
